package 双指针;

public class _006 {
    //和为s的两个数字
    public int[] twoSum(int[] nums, int target) {//和为s的2个数
        int left = 0,right = nums.length-1;
        while (nums[left] + nums[right]!=target) {
            if (nums[left] + nums[right] < target) {
                left++;
            }else {
                right--;
            }
        }
        int[] res = {nums[left],nums[right]};
        return res;
    }
}
